<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box">111</div>
    <script>
        //批量设置元素样式
       function setCss(ele,objstyle){
            for(var key in objstyle){
                //  key--color/backgroundColor
                // ele.style.color=objstyle["color"];
               ele.style[key]=objstyle[key];
            } 
       }

       var objstyle={
         color:"red",
         backgroundColor:"blue"
       }
       setCss(box,objstyle)
    </script>
</body>
</html>